package Template.interfaces;

/**
 * @Author: pengzx
 * @Description:
 * @Date: 14:40 2017/9/15
 * @Modified by: 1.0
 */
public abstract class CaffeineBeverage {
    public final void prepareRecipe(){
        boilWater();
        brew();
        pourInCup();
        if (customerWantsCondiments()){
            addCondiments();
        }
        hook();//钩子，相当于默认方法，子类可以自行覆盖重写
    }

    public abstract void brew();

    public abstract void addCondiments();

    public void boilWater(){
        System.out.println("烧水...");
    }

    public void pourInCup(){
        System.out.println("装杯子...");
    }

    public void hook(){
        System.out.println("default hook...");
    }

    public boolean customerWantsCondiments(){
        return true;
    }
}
